package Day024_枚举_正则表达式.ZuoYe;

import java.util.Scanner;

/**
 * @author zhangyan
 * @date 2020/5/18 16:17
 */
public class Test2 {
    public static void main(String[] args) {

        //键盘录入
        Scanner sc = new Scanner(System.in);
        //无限循环
        while (true) {
            System.out.println("输入身份证号码:");
            String str = sc.nextLine();
            //匹配正则
            boolean b = str.matches("\\d{17}(\\d|X)");
            //判断
            if (b == true) {
                System.out.println("身份证合法!");
                break;
            } else {
                System.out.println("身份证非法!");
            }
        }
    }
}

